#ifndef  __TASK_HPP__
#define  __TASK_HPP__


#include <iostream>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include "Dictionary.hpp"

class Task
{
public:
    Task(int sockfd , std::string message , std::unordered_map<std::string, sockaddr_in>& client)
        :sockfd_(sockfd) , message_(message) , client_(client)
    {
    }

    void operator()()
    {
        for(auto& [ip_ , client] : client_)
        {
            sendto(sockfd_ , message_.c_str() , message_.size() , 0  ,(sockaddr*)&client , sizeof(client));
        }
    }
private:
    int sockfd_;
    std::unordered_map<std::string, sockaddr_in>& client_; 
    std::string message_;
    //static directory dict;
};

//directory Task::dict = directory("words.txt");



#endif
